package com.jwinf.cdLibary.tool;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author jwinf
 * 验证数据有效性的工具类
 */
public class VerifyText {

    // 通过正则判断密码的有效性
    public static boolean veryfyPwd(String pwd){
        Pattern pattern = Pattern.compile("^\\S*(?=\\S{8,20})(?=\\S*\\d)(?=\\S*[A-Z])(?=\\S*[a-z])(?=\\S*[!@#$%^&*?.])\\S*$");
        Matcher matcher = pattern.matcher(pwd);
        return matcher.find();
    }

    // 通过正则判断电话号码的有效性
    public static boolean veryfyTel(String tel){
        Pattern pattern = Pattern.compile("^(?:(?:\\+|00)86)?1(?:(?:3[\\d])|(?:4[5-7|9])|(?:5[0-3|5-9])|(?:6[5-7])|(?:7[0-8])|(?:8[\\d])|(?:9[1|8|9]))\\d{8}$");
        Matcher matcher = pattern.matcher(tel);
        return matcher.find();
    }

}
